package com.wharf.base.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.wharf.base.model.UserInfo;
import com.wharf.base.service.UserInfoService;

/**用户管理*/
@RestController
@RequestMapping("/back")
public class UserManagerController {
	@Autowired
	private UserInfoService userInfoService;
	
	@ResponseBody
	@GetMapping("/infoshow")
	public ResponseEntity<List<UserInfo>> userManage(){
		List<UserInfo> list = userInfoService.userManagement();
		return new ResponseEntity<List<UserInfo>>(list, HttpStatus.OK);
	}
	//根据手机号查询
	@GetMapping("/search")
	public List<UserInfo> search(String phone){
		List<UserInfo> searchByPhone = userInfoService.searchByPhone(phone);
		return searchByPhone;
	}
	//管理员添加新用户
	@GetMapping("/add")
	public boolean addUser(String infoName, String infoPhone, String infoQq, String infoPass){
		boolean addUserAction = userInfoService.addUserAction(infoName, infoPhone, infoQq, infoPass);
		return addUserAction;
	}
	//管理员删除用户
	@GetMapping("/dele")
	public boolean delUser(Integer userId) {
		
		boolean del = userInfoService.delUserInfo(userId);
		return del;
	}
}
